<!-- 患者列表 -->
<template>
    <div class="page-box h100 display-flex czbj">
        <p class="title-label">文书模板列表</p>
        <div class="btm mt10 pt10" v-if="jhher">
            <dxtable :isshowXz="false" :headBtn="headBtnw" :dataJson="dataJson" :portUrl="portUrl" :qx="qx"
                :sonRouter="sonRouter" ref="databale" bjtext="修改"></dxtable>
        </div>

        <n-modal v-model:show="showModalsan" preset="card" class="Stock-diagnosis">
      <template #header>
        <div>新建患者</div>
      </template>
      <div>
        <n-form ref="formRef" :label-width="80">
          <n-form-item label="患者姓名">
            <n-input placeholder="输入模板名称" v-model:value='fromData.name' />
          </n-form-item>

          <n-form-item label="选择模板">
            <n-select v-model:value="fromData.templateId" :options="mnblist" @change="slkertrtw" />
          </n-form-item>
        </n-form>
      </div>
      <template #action>
        <div class="tr">
          <n-button @click="showModalsan = false"> 取消 </n-button>
          <n-button type="success" class="ml20" @click="browse"> 确认 </n-button>
        </div>
      </template>
    </n-modal>
    </div>
</template>
<script lang='ts' setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, hf } from "../../util/index";
import { h, ref, reactive } from "vue";
const showModalsan = ref(false)
const mnblist = ref([])
const databale = ref();
const sonRouter = "addpatient";
const initeer = () => {
    databale.value.initDataExpose();
};
const jhher = ref(false)

const fromData = ref({
    name:"",
    templateId:"",
    templateTtpe:""
})

const headBtnw = ref([
    {
        name: "新增",
        jy: true,
        type: "success",
        clickFun: () => {
            showModalsan.value = true
        },
    },
]);
const slkertrtw = (data)=>{
    fromData.value.templateTtpe=mnblist.value.filter(a=>a.value == data)[0].templateTtpe
}
const browse = ()=>{
    if(!fromData.value.name){
        window.$message.error("请输入患者姓名")
        return
    }
    if(!fromData.value.templateId){
        window.$message.error("请选择模板")
        return
    }
    hf('addpatient',{
        ...fromData.value
    })
}
// 弹窗公用该列表
let dataJson = reactive([
    {
        title: "患者姓名",
        key: "name",
        search: true, // 是否在搜索栏展示
    },
    {
        title: "排序",
        width: 100,
        render(row) {
            row.databaseName = "hlhzinfo";
            return h(sort, {
                row,
                onCallBack: () => {
                    initeer();
                },
            });
        },
    },
    {
        title: "创建时间",
        key: "addTime",
        width: "200",
        type: "daterange",
    },
]);

const getmbse = async () => {
    const { data }: any = await dxget('huli/getMb')
    mnblist.value = data
    jhher.value = true
    dataJson[1].options = [
        {
            label: "全部",
            value: null,
        },
        ...data
    ]
}
getmbse()
let portUrl = "huli/hlhzinfo";
const qx = {
    DeletePermissionID: "patientListdel", //删除
    EditPermissionIdentifier: "patientListbj", // 编辑
    NewPermissionIdentifier: "patientListxz", // 新建
    ViewPermissionID: "patientListck", // 查看
};


</script>
<style scoped>

</style>
  
  
  